export const state = () => ({
    saveList: []
})

export const mutations = {
    addSave(state, data) {
        // 可以做判断, 如果不存在完全一样的数据在进行添加
        let isUnique = true
        state.saveList.forEach(save => {
            if (
               save.title == data.title &&
               save.content == data.content &&
               save.selectCity == data.selectCity
            ) {
                isUnique = false
            }
        });

        if (isUnique) {
            state.saveList.unshift(data)
        }
    },
    handleDelete(state,index) {
        state.saveList.splice(index,1)
    }
}